<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/pageHead.jsp"%>
<script type="text/javascript">
	function view(val){
		var id = val;
		$(this).isswindow({
			noheader : true,
			url :"${systemctx}/dailyoperation/chargemanage/chargeInfoList.web?id="+id
		});
	}
	function query_datagrid(){
		//加载分页控件 datagrid
		$('#datagrid').issdatagrid({
			formid : 'form1',
			title : '收费单管理列表',
			width : 'auto',
			nowrap : true,
			autoRowHeight : false,
			singleSelect : false,
			striped : true,
			url : '${systemctx}/dailyoperation/demandNote/getJson.json',
			sortName : 'modifytime',
			sortOrder : 'desc',
			remoteSort : true,
			idField : 'id',
			pagination : true,
			rownumbers : true,
			showFooter : true,
			queryParams:$('#form1').serializeObject(),
			columns : [[ 
			  {field:'ck', checkbox:true},
			  {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.number")%>',field : 'storenumber',sortable : true,align : 'left',formatter: function(value,row,index){
					return "<a href=\"javascript:void(0);\" onclick=\"view('"+row.id+"')\">"+value+"</a>";
            	}
              },  
              {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.name")%>',field : 'name',sortable : true,align : 'left'},
              {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.demandNote.column.liquidationcycle")%>',field : 'liquidationcycle',sortable : true,align : 'left'},
              {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.demandNote.column.starttime")%>',field : 'starttime',sortable : true,align : 'left'},
              {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.demandNote.column.endtime")%>',field : 'endtime',sortable : true,align : 'left'},
              {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.demandNote.column.amount")%>',field : 'amount',sortable : true,align : 'left'},
              {title : '<%=MessageResourcesUtils.getMessage(request,"dailyoperation.demandNote.column.chargestatus")%>',field : 'chargestatus',sortable : true,align : 'left'}
              /* {field : 'id',title : '操作',width : 100,align : 'center',formatter : function(val, row) {
	      			var str = '';
	    			if(row.state != '3' && row.state != '4'){
	    				str += '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="storeApprove(' + val + ')">审核</a>  ';
	    			}
	    			str  +='<a href="javascript:void(0);" class="easyui-linkbutton" onclick="storeUpdate(' + val + ')">修改</a> ';
	    			return str;
	    		}
              }  */
            ]],
			onLoadSuccess : function(data) {

			}
		});
		
		$("#storecode").issNewMagnifier({
			title: '<%=MessageResourcesUtils.getMessage(request, "systemmanage.databasebinding.storemagnifiertitle") %>',
			url: '${systemctx}/dailyoperation/store/getJson.json',
			sortName : 'modifytime',
			sortOrder : 'desc',
			width : 700,
			height : 550,
			linkName: 'number',
			callSqlKey: '1',
			columns: [[
                {title:'<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.number")%>', field:'number', width:200, sortable:true, align: 'left'},
                {title:'<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.name")%>', field:'name', width:300, sortable:true,formel:'storecode', align: 'left'},
                {field:'id', hidden:true}
            ]],
			onBeforeOpen:function(p){
		      var queryParams = {
		    		  name: '%' + $("#storecode").val() + '%',
		    		  number: '%' + $("#storecode").val() + '%',
		    		  statusid: <%=SysConstant.RecordStatus.VALID %>
		      };
		      return queryParams;
		    }
		});
	}
	function getChangeMethod(){
		var chargemethod  = $("#chargemethod").val();
		if(chargemethod == 1){
			//收费方式
			$("#chargegradient").selectutil({
				optModel : <%=SysConstant.ChargeManage.chargeMethodModelJson(false, false)%>
			});
		}else {
			$("#chargegradient").selectutil({
				optModel : <%=SysConstant.ChargeManage.chargegradientModelJson(true, false)%>
			});
		}
	}
	$(document).ready(function() {
		$("#chargemethod").selectutil({
			optModel : <%=SysConstant.ChargeManage.getModelJSONString(true,false)%>,
			optDefault : '${charge.chargemethod}'
		});
		$("#chargegradient").selectutil({
			optModel : <%=SysConstant.ChargeManage.chargeMethodModelJson(true, false)%>,
			optDefault : '${charge.chargegradient}'
		});
		query_datagrid();
		$('#butQuery').click(function() {
			$('#datagrid').datagrid('load',$('#form1').serializeObject());
		});

		$('#butRest').click(function() {
			$('#currencynum').val('');
			$('#currencyname').val('');
		});
	});
	
	function addStoreInfo(){
		$(this).isswindow({
			noheader : true,
			url :"${systemctx}/dailyoperation/chargemanage/add.web"
		});
	}
	function deleteInfo(flag){
		var ids = getIds(flag);
		if (ids != '' && ids != undefined) {
			var statu = confirm("你确定删除");
		    if(!statu){
		        return false;
		    }
		    delInfo(ids);
		}
	}
	
	function delInfo(ids){
		// 显示进度条
		showSending();
		$.ajax({
			type: 'POST',
		    url: '${systemctx}/dailyoperation/chargemanage/chargeManageDelete.json?ids='+ids,
		    data: $("#form1").serialize(),
		    dataType: 'json',
		    success: function(data) {
		    	//关闭执行...
				closeSending();
		    	if(data.code == 200){
		    		messageAlert("操作成功");
		    		query_datagrid();
		    	}else {
		    		messageAlert(data.message);
		    	}
		    }
		});
	}
	function editInfo(flag){
		var ids = getIds(flag);
		if (ids != '' && ids != undefined) {
			$(this).isswindow({
				noheader : true,
				url :"${systemctx}/dailyoperation/chargemanage/edit.web?id="+ids
			});
		}
	}
	
	function getIds(flag) {
		var ids = "";
		var rows = $('#datagrid').datagrid('getChecked');
		if (rows.length == 0) {
			messageAlert("请选择需要操作的行数据");
			return;
		} else {
			if (flag == 1) {
				if (rows.length > 1) {
					messageAlert("修改不能选择多行数据");
					return;
				} else {
					ids = rows[0].id;
					return ids;
				}
			} else {
				for (var i = 0; i < rows.length; i++) {
					ids += rows[i].id + ",";
				}
				if (ids != '') {
					ids = ids.substring(0,ids.length - 1);
				}
				return ids;
			}
		}
	}
</script>
<form action="" id="form1" name="form1">
	<ul>
		<li>
			<i></i>
			<label>
				<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.name")%>
			</label>
			<span>
				<input type="text" id="storecode" name="storecode" value="" />
				<input type="hidden" id="storeid" name="storeid"  >
			</span>
		</li>
		
	</ul>
	<ul>
		<li>
			<i></i>
			<label>
				<%=MessageResourcesUtils.getMessage(request,"dailyoperation.chargemanage.column.chargemethod") %>
			</label>
			<span><select name="chargemethod" id="chargemethod" onchange="getChangeMethod()"></select></span>
		</li>
		<li>
			<i></i>
			<label>
				<%=MessageResourcesUtils.getMessage(request,"dailyoperation.chargemanage.column.chargegradient") %>
			</label>
			<span><select name="chargegradient" id="chargegradient"></select></span>
		</li>
	</ul>
</form>
<input type="button" class="btn btn-default" id="butQuery" value="查询" />
<input type="button" class="btn btn-default" onclick="addStoreInfo()" value="新增" />
<input type="button" class="btn btn-default" onclick="editInfo(1)" value="修改" />
<input type="button" class="btn btn-default" onclick="deleteInfo(2)" value="删除" />
<table id="datagrid"></table>


<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp" %>
